
<template>
  <section>
    <table>
      <tr>
        <th>姓名/联系人</th>
        <th>手机号</th>
        <th>大分类</th>
        <th v-if="searchInfo.status==1">申请日期</th>
        <th v-if="searchInfo.status==2">通过日期</th>
        <th v-if="searchInfo.status==2">通过编辑</th>
        <th v-if="searchInfo.status==3">未通过日期</th>
        <th v-if="searchInfo.status==3">操作编辑</th>
        <th></th>
      </tr>
      <tr v-for="item in userInfo" class="head">
        <td>{{item.real_name}}</td>
        <td>{{item.call_mobile}}</td>
        <td>{{item.user_type}}</td>
        <td v-if="searchInfo.status==1">{{item.add_time}}</td>
        <td v-if="searchInfo.status==2">{{item.apply_v_time}}</td>
        <td v-if="searchInfo.status==2">通过编辑</td>
        <td v-if="searchInfo.status==3">{{item.apply_v_time}}</td>
        <td v-if="searchInfo.status==3">操作编辑</td>
        <td v-if="searchInfo.status==3">
          <button ><router-link :to="{name:'userApplyDetail',params:{id:item.uid}}">查看</router-link></button>
        </td>
        <td v-if="searchInfo.status!=3">
          <button ><router-link :to="{name:'userApplyDetail',params:{id:item.uid}}">编辑</router-link></button>
        </td>
      </tr>
    </table>
    <el-pagination @size-change="handleSizeChange" @current-change="handleIndexChange" :current-page="searchInfo.page" :page-size="searchInfo.page_size" layout="total, prev, pager, next,jumper,sizes" :total="totalCount">
    </el-pagination>
  </section>
</template>

<script>
  import userService from './UserService.js'
  export default {
    props: {
      userInfo: {
        type: Array
      },
      searchInfo: {
        type: Object
      },
      totalCount: {
        type: Number
      },
      isV: {
        type: Number
      }
    },
    data () {
      return {
        showFreezeDialog: false,
        currentUid: -1
      }
    },
    methods: {
      handleSizeChange (pageSize) {
        this.$emit('pageSizeChange', pageSize)
      },
      goFreeze (uid) {
        this.currentUid = uid
        this.showFreezeDialog = true
      },
      handleIndexChange (pageIndex) {
        this.$emit('pageIndexChange', pageIndex)
      },
      // 获取用户冻结原因
      getFreezedReason (freezeStatus) {
        return freezeStatus
      },
      // 获取用户注册方式
      getRegisterType (registerType) {
        if (registerType === 0) {
          return '手机用户'
        }
        if (registerType === 1) {
          return '三方用户'
        }
        if (registerType === 2) {
          return '邮箱用户'
        }
        return '非法类型'
      },
      cancelFreeze (uid) {
        userService.cancelFreeze(uid).then(response => {
          if (response && response.data && response.data.code === 0) {
            this.$emit('freshFreezeList')
          } else {
            alert(response.data.msg)
          }
        }, response => {
          alert(response)
        })
      },
      onDialogClosed (status) {
        this.showFreezeDialog = status
        if (status) {
          this.$emit('freshFreezeList')
        }
      }
    }
  }
</script>

<style scoped>
  table{
    width: 100%;
  }
</style>
